package org.dnd.rcp.editor.actions;

import org.dnd.rcp.editor.text.IActionsID;
import org.dnd.rcp.editor.text.TextSource;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IEditorPart;

/**
 * Copy Action
 * 
 * @author dendy
 * 
 */

public class CopyTextAction extends Action {

	private TextSource textSource;

	public CopyTextAction() {
		setId(IActionsID.COPY_ID);
	}

	public void setEditor(IEditorPart newEditor) {
		if (newEditor instanceof TextSource)
			textSource = (TextSource) newEditor;
		else
			textSource = null;
	}

	/**
	 * eksekusi text
	 */
	public void run() {
		textSource.getText().copy();
	}

}
